class Student:
    def __init__(self, stu_id, name, age, sex, score):
        self.stu_id = stu_id
        self.name = name
        self.age = age
        self.sex = sex
        self.score = score

    def __str__(self):
        return str(self.__dict__)


class Class:
    def __init__(self, class_name, students):
        self.class_name = class_name
        self.students = students
        # 使self.students从[student_object, ]
        # 变成[dict, ]
        # 方便后面数据的处理
        stu_list = []
        for stu in self.students:
            stu_list.append(stu.__dict__)
        self.students = stu_list

    def show_stu(self):
        for stu in self.students:
            print(stu)

    def id_get_info(self, stu_id):
        for stu in self.students:
            if stu.__dict__['stu_id'] == stu_id:
                print(stu)
                break
        else:
            print('not find')

    def get_info_failed(self):
        failed_num = 0
        for stu in self.students:
            if stu.__dict__['score'] < 60:
                failed_num += 1
                print(stu)
        if failed_num == 0:
            print('no student failed')

    def sort_score(self):
        self.students.sort(key=lambda stu: stu['score'])


s1 = Student('001', 's1', 14, 0, 78)
s2 = Student('002', 's2', 15, 0, 59)
s3 = Student('003', 's3', 14, 1, 80)
s4 = Student('004', 's4', 14, 0, 99)
s5 = Student('005', 's5', 15, 1, 88)
jet_class = Class('class_jet', [s1, s2, s3, s4, s5])
# jet_class.sort_score()
# jet_class.show_stu()
# jet_class.id_get_info('004')
# jet_class.get_info_failed()
